//
//  BlueToothManager.h
//  BlueToothDemo
//
//  Created by US bike on 2017/8/14.
//  Copyright © 2017年 US bike. All rights reserved.
//

#import <Foundation/Foundation.h>




typedef enum : NSUInteger {
    BlueToothResponseTypeReadSucced,//读成功
    BlueToothResponseTypeReadFailue,//读失败
    BlueToothResponseTypeWriteSucced,//写成功
    BlueToothResponseTypeWriteFailue,//写失败
    BlueToothResponseTypeReadSubscriptSucced,//订阅读取成功
    BlueToothResponseTypeReadSubscriptFailue,//订阅读取失败
    
} BlueToothResponseType;


@interface BlueToothResponse : NSObject

@property (nonatomic, assign) BlueToothResponseType type;
@property (nonatomic, copy) NSData *data;
@property (nonatomic, copy) NSString *info;
@property (nonatomic, copy) NSError *error;

@end

typedef void(^BlueToothPeripheralBlock)(Boolean succed, BlueToothResponse * response);
typedef void(^BlueToothFailureBlock)();



//该类用于封装蓝牙通信模块，项目中所有的蓝牙操作核心API都从这里调用
@interface BlueToothManager : NSObject

+ (instancetype) sharedBlueToothManager;

//设置要连接的蓝牙设备的标识 可以通过name
- (void) setupBeforeConnectWithName:(NSString *) nameStr;

//主动发送数据到蓝牙外设
- (void) sendMessageData:(NSData *) sendData;

//读取蓝牙设备返回的数据
- (void) setupReceiveMessageBlock:(BlueToothPeripheralBlock) block;

//获取蓝牙权限的block
- (void) setupBlueToothFailureBlock:(BlueToothFailureBlock) block;

//取消所有连接 以及 停止扫描
- (void) cancellAll;

@end
